using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class SysNavigationMap : EntityTypeConfiguration<SysNavigation>
	{
		public SysNavigationMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.DescValue)
				.IsRequired()
				.HasMaxLength(200);
				
			this.Property(t => t.Slug)
				.IsRequired()
				.HasMaxLength(200);
				
			this.Property(t => t.Url)
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("SysNavigations");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.ParentId).HasColumnName("ParentId");
			this.Property(t => t.NavigationGroupId).HasColumnName("NavigationGroupId");
			this.Property(t => t.DescValue).HasColumnName("DescValue");
			this.Property(t => t.Slug).HasColumnName("Slug");
			this.Property(t => t.Url).HasColumnName("Url");
			this.Property(t => t.SeqOrder).HasColumnName("SeqOrder");

			// Relationships
			this.HasRequired(t => t.SysNavigationGroup)
				.WithMany(t => t.SysNavigations)
				.HasForeignKey(d => d.NavigationGroupId);
				
		}
	}
}

